package com.example.demofdfs.model;

import java.security.Principal;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "user", description = "用户")
public class User extends BaseEntity implements Principal {

	public static final String FINAL_NAME = "final name chenyq";
	
	@ApiModelProperty(value = "性别", required = false)
	private String sex;
	

	@ApiModelProperty(value = "用户菜单")
	private List<Menu> menuList;

	private Date createTime;

	private Date updateTime;

	private Integer createId;

	private Integer updateId;

	public List<Menu> getMenuList() {
		return menuList;
	}

	public void setMenuList(List<Menu> menuList) {
		this.menuList = menuList;
	}


	@Pattern(regexp = "[01]", message = "性别字段,0 男,1女")
	@NotEmpty(message = "性别不能为空")
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getCreateId() {
		return createId;
	}

	public void setCreateId(Integer createId) {
		this.createId = createId;
	}

	public Integer getUpdateId() {
		return updateId;
	}

	public void setUpdateId(Integer updateId) {
		this.updateId = updateId;
	}
	
	public void updateInfo() {
		if (isNew()) {
			this.createTime = new Date();
			this.updateTime = createTime;
			this.createId = 1;
			this.updateId = createId;
		} else {
			this.updateTime = new Date();
			this.updateId = 1;
		}
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + "]";
	}




	
	
}
